const { off } = require("../app/databases");
const connection=require("../app/databases")

class LableService{
    //创建标签
    async createLable(name){  
       const statement=`insert into label (name) values (?)`
       const result=await connection.execute(statement,[name])
       return result[0]; 
    }
    //判断是否标签
    async getLabel(name){ 
        const statement =`select * from label where name=?`
        const result=await connection.execute(statement,[name])
        return result[0];
    }
    //判断动态是否有改标签
    async hasLabel(momentid,id){
        const statement=`select * from moment_label where  moment_id=? and label_id=? `
     
        const result=await connection.execute(statement,[momentid,id])
       
        return result[0];
    }
    //添加动态的标签
    async add(momentid,id){
        const statement=`insert into moment_label (moment_id,label_id) values(?,?)`
        console.log(momentid)
        const result=await connection.execute(statement,[momentid,id])
        return result
    }
    //获取标签列表
    async getCommentList(limit,offset){
        const statement=`select * from moment_label limit ?,?`
        const result=connection.execute(statement,[offset,limit])
        return result;
    }
}
module.exports=new LableService();